const tabBar = require("../../libs/tabBar");
const app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        autoplay: true,
        typeValue: null,
        showRightToast: false,
        changeImg: false,
        show: true,        
        played: false,
        //滑动触点开始的时候
        startPoint: 0,
        currentImageIndex: 0,
        swiperH:'',//swiper高度
         nowIdx:0,//当前swiper索引
         rent:0,
         city_hidden:false,
         status:0,
         crossAxisCount: 2,
         crossAxisGap: 2,
         mainAxisGap:2,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        var open=wx.getStorageSync('open');
   
        if(open == ""){
            console.log('open is null')
            
            wx.navigateTo({
              url: '../login/index?parent_id='+parent_id,
            })
            
        }else{
            console.log('--mine----')
            console.log(open)
            console.log('----mine---')
        }
        let d=app.globalData;
          this.setData({
              open:open,
              platform:d.platform,    
              width:d.windowWidth,
              height:d.windowHeight,
              statusBarHeight:d.statusBarHeight,
              navHeight:d.navHeight,
              marginTop:d.navTitleTop,
              domain:d.domain,
              iUrl:d.iUrl,
              upUrl:d.upUrl
            })
    },
    goto:function(e){
        console.log(e);
        var url=e.currentTarget.dataset.url;
        var index=e.currentTarget.dataset.index;
        app.goto(url,index)
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {
        var role=0;
        var tabIndex=0; 
        this.getIndex();
       // this.update(role)
       // tabBar.updateIndex(this, tabIndex);
    } ,
  getIndex(){
      let that = this;
      var url= '/wechat/Index/getIndex';
      var open = this.data.open
      var data = [];
      data['id'] = open.id;
      data['from'] = 'index';
      var type = 'get';
    app.request(url,data,type).then(res=>{ 
        // console.log(11); 
         console.log(res);
         that.setData({
             banner:res.banner,
             weather:res.weather
         })
       //  that.wxUpdate(); //that.wxLogIn();  
      })
  },
  swiperChange:function(e){
    // console.log(e.detail.current);
       this.setData({
           nowIdx: e.detail.current
       })
   },
   fn:function(e){
     congsole.log(e);
   },
  update(role) {     
     tabBar.updateRole(this,role);
 },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})